package ch.zbw.swt.sysventory.zzzzRIP;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import IMG.GetPath;
import javax.swing.JScrollPane;
import javax.swing.JList;
import java.awt.Choice;
import java.beans.PropertyChangeListener;

import javax.swing.JTextField;

public class GUISuche extends JFrame {

	private JPanel panel;
	
	private ImageIcon goArrow;
	private ImageIcon backArrow;
	
	private JLabel menuTitelLabel;
	private JLabel kriteriumLabel;
	private JLabel suchBegriffLabel;
		
	private JButton go2Search;
	private JButton go2MenuButton;
	
	private JList list;
	
	private Choice choice1;
	private Choice choice2;
	private Choice choice3;
	private Choice choice4;
	private Choice choice5;
	private Choice choice6;
	private Choice choice7;
	private Choice choice8;
	
	private JTextField choice1textField;
	private JTextField choice2textField;
	private JTextField choice3textField;
	private JTextField choice4textField;
	private JTextField choice5textField;
	private JTextField choice6textField;
	private JTextField choice7textField;
	private JTextField choice8textField;

	private Action action;
	private String[][] paket;

	
	/**
	 * Create the application.
	 */
	public GUISuche(Action action) {
		this.action = action;
		choice1textField = new JTextField();
	}
	
	public GUISuche(String computername, Action action) {
		this.action = action;
		choice1textField = new JTextField();
		choice1textField.setText(computername);
	}

	/**
	 * Initialize the contents of the frame.
	 */
	public void initialize() {
		this.getContentPane().setBackground(Color.WHITE);
		this.setBackground(Color.WHITE);
		this.setBounds(100, 100, 770, 480);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().setLayout(null);
		
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int top = (screenSize.height - this.getHeight()) / 2;
		int left = (screenSize.width - this.getWidth()) / 2;
		this.setLocation(left, top);
		
		this.setResizable(false);
		this.setVisible(true);
		
		
		panel = new JPanel();
		panel.setBackground(Color.WHITE);
		panel.setBounds(10, 11, 744, 83);
		this.getContentPane().add(panel);
		panel.setLayout(null);
		
		goArrow = new ImageIcon(
				GetPath.class.getResource("go.png"));			
		backArrow = new ImageIcon(
				GetPath.class.getResource("back.png"));
		
		menuTitelLabel = new JLabel("Suche");
		menuTitelLabel.setFont(new Font("Impact", Font.PLAIN, 36));
		menuTitelLabel.setBounds(322, 11, 209, 61);
		panel.add(menuTitelLabel);
		
		go2Search = new JButton(goArrow);
		go2Search.setBackground(Color.WHITE);
		go2Search.setBounds(592, 11, 129, 61);
		go2Search.setBorder(null);
		panel.add(go2Search);
		
		go2MenuButton = new JButton(backArrow);
		go2MenuButton.setBackground(Color.WHITE);
		go2MenuButton.setBounds(20, 11, 129, 61);
		go2MenuButton.setBorder(null);
		panel.add(go2MenuButton);
		
		
		go2Search.addActionListener(action);
		go2Search.setActionCommand("go2search");
		go2MenuButton.addActionListener(action);
		go2MenuButton.setActionCommand("back2Menu");
		
		list = new JList();
		list.setBounds(84, 212, -33, -21);
		this.getContentPane().add(list);
		
		choice1 = new Choice();
		choice1.setBounds(166, 171, 180, 20);
		this.getContentPane().add(choice1);
		
		choice2 = new Choice();
		choice2.setBounds(166, 197, 180, 20);
		this.getContentPane().add(choice2);
		
		choice3 = new Choice();
		choice3.setBounds(166, 223, 180, 20);
		this.getContentPane().add(choice3);
		
		choice4 = new Choice();
		choice4.setBounds(166, 249, 180, 20);
		this.getContentPane().add(choice4);
		
		choice5 = new Choice();
		choice5.setBounds(166, 275, 180, 20);
		this.getContentPane().add(choice5);
		
		choice6 = new Choice();
		choice6.setBounds(166, 301, 180, 20);
		this.getContentPane().add(choice6);
		
		choice7 = new Choice();
		choice7.setBounds(166, 327, 180, 20);
		this.getContentPane().add(choice7);
		
		choice8 = new Choice();
		choice8.setBounds(166, 353, 180, 20);
		this.getContentPane().add(choice8);
		
		choice1textField.setBounds(436, 171, 180, 20);
		this.getContentPane().add(choice1textField);
		choice1textField.setColumns(10);
		
		choice2textField = new JTextField();
		choice2textField.setColumns(10);
		choice2textField.setBounds(436, 197, 180, 20);
		this.getContentPane().add(choice2textField);
		
		choice3textField = new JTextField();
		choice3textField.setColumns(10);
		choice3textField.setBounds(436, 223, 180, 20);
		this.getContentPane().add(choice3textField);
		
		choice4textField = new JTextField();
		choice4textField.setColumns(10);
		choice4textField.setBounds(436, 249, 180, 20);
		this.getContentPane().add(choice4textField);
		
		choice5textField = new JTextField();
		choice5textField.setColumns(10);
		choice5textField.setBounds(436, 275, 180, 20);
		this.getContentPane().add(choice5textField);
		
		choice6textField = new JTextField();
		choice6textField.setColumns(10);
		choice6textField.setBounds(436, 301, 180, 20);
		this.getContentPane().add(choice6textField);
		
		choice7textField = new JTextField();
		choice7textField.setColumns(10);
		choice7textField.setBounds(436, 327, 180, 20);
		this.getContentPane().add(choice7textField);
		
		choice8textField = new JTextField();
		choice8textField.setColumns(10);
		choice8textField.setBounds(436, 353, 180, 20);
		this.getContentPane().add(choice8textField);
		
		kriteriumLabel = new JLabel("Kriterium");
		kriteriumLabel.setFont(new Font("Impact", Font.PLAIN, 16));
		kriteriumLabel.setBounds(166, 135, 180, 30);
		this.getContentPane().add(kriteriumLabel);
		
		suchBegriffLabel = new JLabel("Suchbegriff");

		suchBegriffLabel.setFont(new Font("Impact", Font.PLAIN, 16));
		suchBegriffLabel.setBounds(436, 135, 180, 30);
		this.getContentPane().add(suchBegriffLabel);
		
		
	}
	
	public String[][] getPaket(){
		
		paket = new String[8][2];
		
		paket[0][0] = choice1.getName();
		paket[0][1] = choice1textField.getText();
		
		paket[1][0] = choice2.getName();
		paket[1][1] = choice2textField.getText();
		
		paket[2][0] = choice3.getName();
		paket[2][1] = choice3textField.getText();
		
		paket[3][0] = choice4.getName();
		paket[3][1] = choice4textField.getText();
		
		paket[4][0] = choice5.getName();
		paket[4][1] = choice5textField.getText();
		
		paket[5][0] = choice6.getName();
		paket[5][1] = choice6textField.getText();
		
		paket[6][0] = choice7.getName();
		paket[6][1] = choice7textField.getText();
		
		paket[7][0] = choice8.getName();
		paket[7][1] = choice8textField.getText();
				
		return paket;
	}
	
}
